package com.yunzhong.appointment.system.controller;

import com.yunzhong.appointment.entity.Appointmentorder;
import com.yunzhong.appointment.entity.Department;
import com.yunzhong.appointment.entity.Departmenttype;
import com.yunzhong.appointment.system.service.DepartmenttypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * 科室类别
 * 刘凡博
 */
@Controller
public class DepartmenttypeController {
    @Autowired
    private DepartmenttypeService departmenttypeService;

    @RequestMapping("depttype/query")
    public String query(ModelMap mm, HttpServletRequest request) {
        List<Departmenttype> list = departmenttypeService.selectAll();
        for (int i = 0; i < list.size(); i++) {
            String id = list.get(i).getDplId();
            List<Department> namelist = departmenttypeService.selectById(id);
            list.get(i).setDeptList(namelist);
        }
        List<Appointmentorder> count = departmenttypeService.selectCount();
        mm.addAttribute("list", list);
        mm.addAttribute("count", count);
        return "appointment/dept/listDept";
    }
}


